﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Sharp.DataTransferObject;
using Sharp.Infrastructure.Interfaces;
using Sharp.Portal;
using Sharp.Portal.AdminLTE;
using Sharp.Portal.Mvc.List;
using Sharp.Portal.Other;

namespace Sharp.WebBooter.Areas.Platform.Models
{
    [ModuleCode("OrgManage"), Title("组织结构管理"), ModuleItem(typeof(OrgViewModel))]
    [DataHandler(ModuleOP.Details, "浏览", 0)]
    [DataHandler(ModuleOP.Create, "新增", 1)]
    [DataHandler(ModuleOP.Edit, "修改", 2)]
    [DataHandler(ModuleOP.Delete, "删除", 3)]
    [DataHandler(ModuleOP.Refresh, "刷新", 4)]
    public class OrgIndexViewModel : BSSharpTreeList, ITreeEntity<Guid>
    {
        public OrgIndexViewModel()
        {
            this.Feature = ListFeature.MultiSelect;
            this.Breadcrumb = "<ol class=\"breadcrumb\"> <li><a href =\"@Url.Action(\"Index\", \"Home\")\"><i class=\"fa fa-home\"></i> 首页</a></li> <li class=\"active\">组织结构</li> </ol>";
        }

        /// <summary>
        /// 编码
        /// </summary>
        [Column(Width = 120, Text = "编码", Order = 2)]
        public string Code { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        /// <value>标题</value>
        [TreeColumn(Width = 240, Text = "名称", TemplateString = "<a class=\"auto\" data-toggle=\"ajaxLoad\" href=\"@Url.Action(\"Edit\")/@item.Id\">@item.Title</a>", Order = 1), QueryOption(Option = QueryFeature.DefualtQuery)]
        public string Title { get; set; }
        /// <summary>
        /// 简称
        /// </summary>
        public string Abbreviation { get; set; }
        /// <summary>
        /// 层级Id
        /// </summary>
        public Guid? OrgLevelId { get; set; }

        /// <summary>
        /// 编制
        /// </summary>
        [NumberColumn(Width = 100, Text = "最大编制", Order = 3)]
        public int? MaxHeadcount { get; set; }

        /// <summary>
        /// 当前编制
        /// </summary>
        [NumberColumn(Width = 100, Text = "当前编制", Order = 4)]
        public int? CurrentHeadcount { get; set; }

        /// <summary>
        /// 所在区域
        /// </summary>
        /// <value>所在区域</value>
        [Column(Text = "所在区域", Order = 6), MasterData("AdministrativeDivision")]
        public string AreaCode { get; set; }

        /// <summary>
        /// 层级
        /// </summary>
        [Display(Name = "层级")]
        public OrgLevelDTO OrgLevel { get; set; }

        /// <summary>
        /// 组织路径
        /// </summary>
        [Column(Text = "组织路径", Order = 5)]
        public string OrgPath { get; set; }

        /// <summary>
        /// 为控件显示用的属性
        /// </summary>
        /// <![CDATA[<treegrid-@Model.Id treegrid-parent-@Model.ParentId>]]>
        public string Itemclass { get; set; }

        /// <summary>
        /// 树形数据源
        /// </summary>
        public List<OrgIndexViewModel> Data { get; set; }
        public Guid? ParentId { get; set; }
        public Guid Id { get; set; }
        public int OrderIndex { get; set; }

    }
}